<template>
	<basic-container>
		<avue-crud :option="option" :data="data" :page="page" ref="crud" @search-change="searchChange" @search-reset="searchReset"
		 @current-change="currentChange" @size-change="sizeChange" @on-load="onLoad">
		</avue-crud>
	</basic-container>
</template>

<script>
	import request from '@/router/axios';

	export default {
		props: {
			pid: "",
			bar: ""
		},
		data() {
			return {
				query: {},
				page: {
					pageSize: 10,
					currentPage: 1,
					total: 0
				},
				option: {
					border: true,
					index: true,
					menu: false,
					addBtn: false,
					columnBtn: false,
					header:false,
					refreshBtn: false,
					showSummary: true,
					sumColumnList: [{
						name: 'quantity',
						type: 'sum'
					}],
					column: [{
							label: "相关单号",
							prop: "mainCode",
							width: 140
						}, {
							label: "库位",
							prop: "localCode",
							width: 100
						},
						{
							label: "条码",
							prop: "barCode"
						},
						{
							label: "数量",
							prop: "quantity",
							width: 60
						},
						{
							label: "操作时间",
							prop: "updatedOn",
							width: 160
						},
						{
							label: "操作人",
							prop: "createdBy",
							width: 100
						}
					]
				},
				data: []
			};
		},
		created() {
			this.query.mainCode = this.pid;
			this.query.barCode = this.bar;
		},
		methods: {
			searchReset() {
				this.query = {};
				this.page.currentPage = 1;
				this.onLoad(this.page);
			},
			searchChange(params, done) {
				this.page.currentPage = 1;
				this.query = params;
				this.onLoad(this.page);
				done();
			},
			currentChange(currentPage) {
				this.page.currentPage = currentPage;
			},
			sizeChange(pageSize) {
				this.page.pageSize = pageSize;
			},
			onLoad(page) {
				request({
					url: '2/api/WmsLog/getpages',
					method: 'get',
					params: {
						key: this.bar,
						type: this.pid,
						status: 1,
						page: page.currentPage,
						limit: page.pageSize
					}
				}).then(res => {
					const data = res.data
					this.data = data.data;
					this.page.total = data.remark;
				});
			}
		},
		computed: {
			// pidbar() {
			// 	return this.pid + "_" + this.bar;
			// }
		},
		watch: {
			// pidbar(val) {
			// 	if (val !== undefined && val !== null && val !== "") {
			// 		this.page.currentPage = 1;
			// 		this.onLoad(this.page);
			// 	}
			// }
		}
	};
</script>

<style>
</style>
